package com.anyou.mall.goo.goodsAudit.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.anyou.common.annotation.ShopScope;
import com.anyou.mall.goo.goods.dto.GoodsSearchParams;
import com.anyou.mall.goo.goodsAudit.vo.GoogdsDetailVo;
import com.anyou.mall.goo.goodsAudit.vo.SelectGoodsSpecsVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.goo.goodsAudit.domain.goodsAudit;
import com.anyou.mall.goo.goodsAudit.service.IgoodsAuditService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * 商品审核Controller
 *
 * @author ruoyi
 * @date 2022-03-25
 */
@Api(tags = "商品审核")
@RestController
@RequestMapping("/goodsAudit/goodsAuditType")
public class goodsAuditController extends BaseController
{
    @Autowired
    private IgoodsAuditService goodsAuditService;

    /**
     * 查询商品审核列表
     */
    @ApiOperation("查询商品审核列表")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:list')")
    @GetMapping("/list")
    @ShopScope(baseTableAlias="g")
    public TableDataInfo<List<goodsAudit>> list(GoodsSearchParams goodsSearchParams)
    {
        startPage();
        List<goodsAudit> list = goodsAuditService.selectgoodsAuditList(goodsSearchParams);
        return getDataTable(list);
    }

    /**
     * 导出商品审核列表
     */
/*    @ApiOperation("导出商品审核列表")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:export')")
    @Log(title = "商品审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ShopScope(baseTableAlias="g")
    public void export(HttpServletResponse response, goodsAudit goodsAudit)
    {
        List<goodsAudit> list = goodsAuditService.selectgoodsAuditList(goodsAudit);
        ExcelUtil<goodsAudit> util = new ExcelUtil<goodsAudit>(goodsAudit.class);
        util.exportExcel(response, list, "商品审核数据");
    }*/

    /**
     * 获取商品审核详细信息
     */
/*    @ApiOperation("获取商品审核详细信息")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:query')")
    @GetMapping(value = "/{goodsId}")
    public ApiResult<goodsAudit> getInfo(@PathVariable("goodsId") Long goodsId)
    {
        return ApiResult.success(goodsAuditService.selectgoodsAuditByGoodsId(goodsId));
    }*/

    /**
     * 新增商品审核
     */
/*    @ApiOperation("新增商品审核")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:add')")
    @Log(title = "商品审核", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody goodsAudit goodsAudit)
    {
        return ApiResult.success(goodsAuditService.insertgoodsAudit(goodsAudit));
    }*/

    /**
     * 修改商品审核
     */
   /* @ApiOperation("修改商品审核")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:edit')")
    @Log(title = "商品审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody goodsAudit goodsAudit)
    {
        return ApiResult.success(goodsAuditService.updategoodsAudit(goodsAudit));
    }*/

    /**
     * 删除商品审核
     */
    /*@ApiOperation("删除商品审核")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:remove')")
    @Log(title = "商品审核", businessType = BusinessType.DELETE)
    @DeleteMapping("/{goodsIds}")
    public ApiResult remove(@PathVariable Long[] goodsIds)
    {
        return ApiResult.success(goodsAuditService.deletegoodsAuditByGoodsIds(goodsIds));
    }*/

    /**
     * 获取商品规格和SKU详细信息
     */
    /*@ApiOperation("获取商品规格和SKU详细信息")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:goodsSpecs')")
    @GetMapping(value = "/findGoodsSku/{goodsId}")
    public ApiResult<SelectGoodsSpecsVo> selectGoodsSpecs(@PathVariable Long goodsId)
    {
        return goodsAuditService.selectGoodsSpecs(goodsId);
    }*/

    @ApiOperation("审核状态(可以批量操作)（0待审核 1通过 2不通过）")
    @PreAuthorize("@ss.hasPermi('goods:goodsList:updateViolationStatus')")
    @Log(title = "商品", businessType = BusinessType.UPDATE)
    @PostMapping("/updateViolationStatus")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodsId", dataType = "Long", required = true, value = "商品编号"),
            @ApiImplicitParam(name = "auditStatus", dataType = "String", required = true, value = "审核状态（0待审核 1通过 2不通过）"),
            @ApiImplicitParam(name = "auditRemark", dataType = "String", required = false, value = "审核备注")
    })
    public ApiResult updateViolationStatus(@RequestParam Long[] goodsId , @RequestParam String auditStatus, @RequestParam String auditRemark)
    {
        return goodsAuditService.updateAuditStatus(goodsId,auditStatus,auditRemark);
    }


    /**
     * 查询商品审核详细
     */
/*    @ApiOperation("查询商品审核详细")
    @PreAuthorize("@ss.hasPermi('goodsAudit:goodsAuditType:GoogdsDetail')")
    @GetMapping("/GoogdsDetail")
    public ApiResult<GoogdsDetailVo> GoogdsDetail(@RequestParam Long goodsId)
    {

        return goodsAuditService.GoogdsDetail(goodsId);
    }*/
}
